﻿using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Text;

namespace OddUserManager.Model
{
    /// <summary>
    /// 投注清单
    /// </summary>
    public class Odd : Entity
    {
        /// <summary>
        /// 发单时间
        /// </summary>
        [JsonConverter(typeof(LongDateTimeConvert))]
        public DateTime CreateTime { get; set; }
        /// <summary>
        /// 预约截止时间
        /// </summary>
        [JsonConverter(typeof(LongDateTimeConvert))]
        public DateTime BespeakCutoffTime { get; set; }
        /// <summary>
        /// 跟单截止时间
        /// </summary>
        [JsonConverter(typeof(LongDateTimeConvert))]
        public DateTime DocumentaryCutoffTime { get; set; }
        /// <summary>
        /// 购彩站点ID
        /// </summary>
        public int SiteId { get; set; }
        /// <summary>
        /// 购彩站点
        /// </summary>
        [DapperIgnore]
        public Site Site { get; set; }
        /// <summary>
        /// 账号
        /// </summary>
        public int CreateOddUserId { get; set; }

        [DapperIgnore]
        public string CreateOddUserName { get; set; }
        /// <summary>
        /// 自购金额
        /// </summary>
        public decimal OwnPurchaseMoney { get; set; }
        /// <summary>
        /// 跟单人数
        /// </summary>
        public int DocumentaryUserCount { get; set; }
        /// <summary>
        /// 跟单金额
        /// </summary>
        public decimal DocumentaryMoney { get; set; }
        /// <summary>
        /// 自购返点金额
        /// </summary>
        public decimal OwnPurchaseRebate { get; set; }
        /// <summary>
        /// 跟单返点金额
        /// </summary>
        public decimal DocumentaryRebate { get; set; }
        /// <summary>
        /// 自购奖金
        /// </summary>
        public decimal OwnBonus { get; set; }
        /// <summary>
        /// 跟单奖金
        /// </summary>
        public decimal DocumentaryBonus { get; set; }
        /// <summary>
        /// 预估提成
        /// </summary>
        public decimal EstimatedCommission { get; set; }
        /// <summary>
        /// 实际提成
        /// </summary>
        public decimal ActualCommission { get; set; }
        /// <summary>
        /// 操盘用户ID
        /// </summary>
        public int AppUserId { get; set; }
        [DapperIgnore]
        public string AppUserName { get; set; }
        [DapperIgnore]
        public string LastEditAppUserName { get; set; }

        public int LastEditAppUserId { get; set; }
        /// <summary>
        /// 赔率公约数
        /// </summary>
        public int Divisor { get; set; }
        /// <summary>
        /// 开奖时间
        /// </summary>
        [JsonConverter(typeof(LongDateTimeConvert))]
        public DateTime LotteryTime { get; set; }
        /// <summary>
        /// 状态
        /// </summary>

        public OddState State { get; set; }
        /// <summary>
        /// 投注方式
        /// </summary>
        public string BetWay { get; set; }
        /// <summary>
        /// 备注
        /// </summary>

        public string Remark { get; set; }

        /// <summary>
        /// 确认是否发单
        /// </summary>
        public bool Certification { get; set; }
        /// <summary>
        /// 确认人
        /// </summary>
        public int ConfirmAppUserId { get; set; }

        /// <summary>
        /// 确认人名字
        /// </summary>
        [DapperIgnore]
        public string ConfirmAppUserName { get; set; }
        /// <summary>
        /// 是否中奖
        /// </summary>
        public LotteryResults Result { get; set; }

        /// <summary>
        /// 排序字段
        /// </summary>
        public string OrderString { get; set; }
        /// <summary>
        /// 排序字段
        /// </summary>
        public int OrderInt { get; set; }
        /// <summary>
        /// 说明
        /// </summary>

        public string Descption { get; set; }


        public string Title { get; set; }
        /// <summary>
        /// 盈亏
        /// </summary>
        public decimal ProfitAndLoss { get; set; }
        [DapperIgnore]
        public List<BetDetailOdd> BetDetailOddList { get; set; }

        [DapperIgnore]
        public List<OddSelectedMatchs> OddSelectedMatchList { get; set; }
    }

    /// <summary>
    /// 详细投注订单
    /// </summary>
    public class BetDetailOdd : Entity
    {

        public BetDetailOdd()
        {
            LotteryResults = LotteryResults.未开奖;
            BetDetailOddContentsList = new List<BetDetailOddContents>();
        }
        public int OddId { get; set; }
        public int BetCount { get; set; }
        public string Remark { get; set; }
        public decimal Bonus { get; set; }

        public LotteryResults LotteryResults { get; set; }
        [DapperIgnore]
        public List<BetDetailOddContents> BetDetailOddContentsList { get; set; }
    }

    public class ReportBetDetailOdd : BetDetailOdd
    {
        public int MatchId { get; set; }
        public string CreateOddUserName { get; set; }
        public SelectedResult SelectedResult { get; set; }
        public decimal SelectedOdds { get; set; }
    }

    /// <summary>
    /// 详细的投注比赛选项
    /// </summary>
    public class BetDetailOddContents : Entity
    {

        public BetDetailOddContents()
        {
            LotteryResults = LotteryResults.未开奖;
        }
        public string WeekName { get; set; }
        public int BetDetailOddId { get; set; }
        public int SelectedMatchId { get; set; }
        public SelectedResult SelectedResult { get; set; }

        public string FixOdds { get; set; }
        public decimal SelectedOdds { get; set; }

        public LotteryResults LotteryResults { get; set; }
    }

    public class LongDateTimeConvert : IsoDateTimeConverter
    {
        public LongDateTimeConvert() : base()
        {
            base.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
        }
    }

    public class BigShortDateTimeConvert : IsoDateTimeConverter
    {
        public BigShortDateTimeConvert() : base()
        {
            base.DateTimeFormat = "HH:mm";
        }
    }



    public class ShortDateTimeConvert : IsoDateTimeConverter
    {
        public ShortDateTimeConvert() : base()
        {
            base.DateTimeFormat = "yyyy-MM-dd";
        }
    }

    public class OddSelectedMatchs : Entity
    {
        public int OddId { get; set; }
        public int SelectedMatchId { get; set; }
        public int SelectedJCHadOddId { get; set; }
        public int SelectedJCHHadOddId { get; set; }
        public int SelectedJCHAFUOddId { get; set; }
        public string SelectedJCHadOdds { get; set; }
        public string SelectedJCHHadOdds { get; set; }
        public string SelectedJCHAFUOdds { get; set; }

        public bool Dan { get; set; }
    }

}
